/**
 ** This file is part of FK Klistret Extensions. FK Klistret Extensions 
 ** is free software: you can redistribute it and/or modify it under the 
 ** terms of the GNU General Public License as published by the Free 
 ** Software Foundation, either version 3 of the License, or (at your option) 
 ** any later version.

 ** FK Klistret Extensions is distributed in the hope that it will be 
 ** useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 ** General Public License for more details. You should have received a
 ** copy of the GNU General Public License along with FK Klistret Extensions. 
 ** If not, see <http://www.gnu.org/licenses/>
 */
package se.fk.klistret.console.ui;

import java.util.EventObject;

/**
 * 2011-07-11, The comments below are from 2005 and the code is has since
 * upgraded to the Ant 1.8 platform. The patterns and design of this project
 * should not be reused since they are not considered of any quality. The code
 * was written quickly without long term concerns.
 * <p>
 * 
 * 2005, TextMenuEvent defines the event object passed to TextMenu listeners and
 * characterises events based on static identifiers. Depending on whether an
 * event is the result of an expression entered, an item selected, or menu items
 * being displayed the source which fired the event is always passed.
 * 
 * @author Matthew Young
 */
@SuppressWarnings("serial")
public class TextMenuEvent extends EventObject {
	/**
	 * Expression (dvs written text) entered at the command line or Menu prompt
	 */
	public static int ACTION_EXPRESSION = 0001;

	/**
	 * Item selected at the command line or Menu prompt
	 */
	public static int ACTION_ITEM = 0002;

	/**
	 * Displaying Menu Items
	 */
	public static int ACTION_DISPLAY = 0003;

	/**
	 * ACTIION static integer
	 */
	private int identifier;

	/**
	 * Most likely the expression entered from an ACTION_EXPRESSION event
	 */
	private String command;

	/**
	 * Returns event identifier (public static integer)
	 * 
	 * @return <code>int</code>
	 * 
	 */
	public int getIdentifier() {
		return this.identifier;
	}

	/**
	 * Returns expression for ACTION_EXPRESSION events
	 * 
	 * @return <code>String</code>
	 * 
	 */
	public String getCommand() {
		return this.command;
	}

	/**
	 * Returns object which fired the event
	 * 
	 * @return <code>Object</code>
	 * 
	 */
	public Object getSource() {
		return this.source;
	}

	/**
	 * Constructs basic Event object, setting the event identifier
	 * 
	 * @param source
	 *            <code>Object</code>
	 * @param identifier
	 *            <code>int</code>
	 * 
	 */
	public TextMenuEvent(Object source, int identifier) {

		super(source);

		this.identifier = identifier;

	}

	/**
	 * Constructs Event object, setting the command string
	 * 
	 * @param source
	 *            <code>Object</code>
	 * @param identifier
	 *            <code>int</code>
	 * @param command
	 *            <code>String</code>
	 * 
	 */
	public TextMenuEvent(Object source, int identifier, String command) {

		this(source, identifier);

		this.command = command;

	}

}
